package com.ce.pms.customer.dao.impl;

import java.util.List;

import org.hibernate.Query;

import com.ce.pms.base.dao.impl.PmsBaseDaoImpl;
import com.ce.pms.customer.dao.IRelationTypeDao;
import com.ce.pms.customer.model.RelationTypeDO;

public class RelationTypeDaoImpl extends PmsBaseDaoImpl<RelationTypeDO> implements IRelationTypeDao{

	public RelationTypeDO getRelationTypeByCode(String relationTypeCode) {
		RelationTypeDO relationTypeDO = new RelationTypeDO();
		StringBuffer hql = new StringBuffer();
		hql.append(" SELECT relationType FROM RelationTypeDO relationType WHERE relationType.relationTypeCode=? ");
		Query query=super.createQuery(hql.toString(), relationTypeCode);
		if(query.list().size()>0) {
		  relationTypeDO = (RelationTypeDO)query.list().get(0);
		}
		return relationTypeDO;
	}

	public List<RelationTypeDO> getRelationType(){
		return super.findAll();
	}

	public List<RelationTypeDO> getRelationOfMember() {
		StringBuffer hql = new StringBuffer();
		hql.append(" SELECT relationType FROM RelationTypeDO relationType WHERE relationType.relationTypeCode in ('001','002','003','004','005','008') ");
		Query query=super.createQuery(hql.toString());
		return query.list();
	}

}
